home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ShowSystemVolumeID.c
-
- Contains:
-
- Written by: Martin Minow
-
- Copyright: Copyright © 1992-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/14/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
- #include <Folders.h>
- #include <GestaltEqu.h>
- #include <Files.h>
- #include <Devices.h>
- #include <Memory.h>
- #include <Traps.h>
- #include <stdio.h>
- void ShowSystemVolumeName(void);
- void ShowSCSIDeviceIdent(
- short driverRefNum
- );
-
- static void
- ClearMemory(
- Ptr ptr,
- Size size
- )
- {
- while (size > 0) {
- *ptr++ = 0;
- --size;
- }
- }
-
-
- void
- ShowSystemVolumeName(void)
- {
- OSErr status;
- long gestaltResult;
- short systemVRefNum;
- long systemFolderDirID;
- HVolumeParam pb;
- Str255 systemVolumeName;
-
- status = Gestalt(gestaltFindFolderAttr, &gestaltResult);
- if (status == noErr) { /* We have FindFolder */
- status = FindFolder(
- kOnSystemDisk,
- kSystemFolderType,
- kDontCreateFolder,
- &systemVRefNum,
- &systemFolderDirID
- );
- }
- if (status == noErr) {
- ClearMemory((Ptr) &pb, sizeof pb);
- pb.ioVolIndex = 0;
- pb.ioNamePtr = systemVolumeName;
- pb.ioVRefNum = systemVRefNum;
- status = PBHGetVInfoSync((HParmBlkPtr) &pb);
- }
- if (status == noErr) {
- printf("Boot volume \"%.*s\", drive %d, driver %d",
- systemVolumeName[0],
- &systemVolumeName[1],
- pb.ioVDrvInfo,
- pb.ioVDRefNum
- );
- ShowSCSIDeviceIdent(pb.ioVDRefNum);
- printf("\n");
- }
- }
-